import axios from "./axios"
export default {
    // 用户管理
    getUserList(queryInfo) {
        return axios.get("users", { params: queryInfo })
    },
    userStateChanged(id, mg_state) {
        return axios.put(`users/${id}/state/${mg_state}`)
    },
    addUser(addForm) {
        return axios.post("users", addForm)
    },
    showEditDialog(id) {
        return axios.get("users/" + id)
    },
    editUserInfo(id, email, mobile) {
        return axios.put("users/" + id, {
            email: email,
            mobile: mobile
        })
    },
    submitForm(ruleForm) {
        return axios.post("login", ruleForm)
    },
    navAdd() {
        return axios.get("menus")
    },
    removeUserById(id) {
        return axios.delete("users/" + id)
    },
    setRole() {
        return axios.get("roles")
    },
    saveRoleInfo(id, selectedRoleId) {
        return axios.put(`users/${id}/role`, {
            rid: selectedRoleId
        })
    },
    // 角色列表
    getLists() {
        return axios.get("roles")
    },
    removeRightById(id, rightId) {
        return axios.delete(`roles/${id}/rights/${rightId}`)
    },
    addFormList(addForm) {
        return axios.post("roles", addForm)
    },
    edit(id) {
        return axios.get(`roles/${id}`)
    },
    editFormList(roleId, editForm) {
        return axios.put("roles/" + roleId, editForm)
    },
    delDialogVisible(id) {
        return axios.delete("roles/" + id)
    },
    showSetRightDialong() {
        return axios.get("rights/tree")
    },
    allotRights(roleId, idStr) {
        return axios.post(`roles/${roleId}/rights`, { idStr })
    },


    // 权限列表
    getList() {
        return axios.get("rights/list")
    },

    // 商品列表
    getGoodsList(queryInfo) {
        return axios.get("goods", { params: queryInfo })
    },
    removeById(id) {
        return axios.delete(`goods/${id}`)
    },
    // 添加商品列表
    getCateList() {
        return axios.get("categories")
    },
    handleClick(goods_cat) {
        return axios.get(`categories/${goods_cat}/attributes`, {
            params: { sel: "many" }
        })
    },
    handleClicks(goods_cat) {
        return axios.get(`categories/${goods_cat}/attributes`, {
            params: { sel: "only" }
        })
    },
    handleAdd(form) {
        return axios.post("goods", form)
    },

    // 分类参数
    getCateList() {
        return axios.get("categories")
    },
    getParamsData(cateId, activeName) {
        return axios.get(`categories/${cateId}/attributes`, {
            params: { sel: activeName }
        })
    },
    addParams(cateId, attr_name, activeName) {
        return axios.post(`categories/${cateId}/attributes`, {
            attr_name: attr_name,
            attr_sel: activeName
        })
    },
    showEditDialogs(cateId, attr_id, activeName) {
        return axios.get(`categories/${cateId}/attributes/${attr_id}`, {
            params: { attr_sel: activeName }
        })
    },
    editParams(cateId, attr_id, attr_name, activeName) {
        return axios.put(
            `categories/${cateId}/attributes/${attr_id}`,
            {
                attr_name: attr_name,
                attr_sel: activeName
            })
    },
    removeParams(cateId, attr_id) {
        return axios.delete(`categories/${cateId}/attributes/${attr_id}`)
    },
    saveAttrVals(cateId, attr_id, attr_name, attr_sel, attr_vals) {
        return axios.put(`categories/${cateId}/attributes/${attr_id}`, {
            attr_name: attr_name,
            attr_sel: attr_sel,
            attr_vals: attr_vals.join(" ")
        })
    },
    // 商品分类
    getCatList(queryInfo) {
        return axios.get("categories", { params: queryInfo })
    },
    getParentCateList() {
        return axios.get("categories", { params: { type: 2 } })
    },
    addCate(addCateForm) {
        return axios.post("categories", addCateForm)
    },
    showEditCateDialog(id) {
        return axios.get("categories/" + id)
    },
    editCate(cat_id, editCateForm) {
        return axios.put("categories/" + cat_id, editCateForm)
    },
    showDelCateDialog(id) {
        return axios.delete("categories/" + id)
    },


    // 订单列表
    gerOrderList(queryInfo) {
        return axios.get("orders", { params: queryInfo })
    },
    showProgressBox() {
        return axios.get("/kuaidi/804909574412544580")
    },


    // 折线图
    reports() {
        return axios.get("reports/type/1")
    },

} 